package com.school.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.school.dao.HljtWebHomeDao;
import com.school.entity.HljtDevice;
import com.school.entity.web.HljtDeviceInfo;
import com.school.entity.web.SchoolNumberInfo;
import com.school.service.HljtWebHomeService;
import com.school.util.MapperToJson;
@Service
public class HljtWebHomeServiceImpl implements HljtWebHomeService {

	@Autowired
	HljtWebHomeDao oDao;
	@Override
	public int findDeviceCount() {
		return oDao.findDeviceCount();
	}
	@Override
	public String findDeviceInfo(int pageIndex, int pageSize) {
		List<HljtDeviceInfo> list=new ArrayList<HljtDeviceInfo>();
		pageIndex=(pageIndex-1)*pageSize;
		HashMap<String,Object> oMap=new HashMap<String,Object>(); 
		oMap.put("Sum", oDao.findDeviceCount());
		list=oDao.findDeviceInfo(pageIndex, pageSize);
		oMap.put("Info", list);
		return MapperToJson.toJson(oMap);
	}
	@Override
	public String findSchoolNumberCount() {
		SchoolNumberInfo oSchoolNumberInfo=new SchoolNumberInfo();
		oSchoolNumberInfo.setnGrade(oDao.findnGradeCount());
		oSchoolNumberInfo.setnClass(oDao.findnClassCount());
		oSchoolNumberInfo.setnStudent(oDao.findnStudentCount());
		oSchoolNumberInfo.setnHeadmaster(oDao.findnHeadmasterCount());
		oSchoolNumberInfo.setnOteacher(oDao.findnOteacherCount());
		oSchoolNumberInfo.setnDevice(oDao.findnDeviceCount());
		oSchoolNumberInfo.setnDevice_Use(oDao.findnDevice_UseCount());
		return MapperToJson.toJson(oSchoolNumberInfo);
	}

}
